<template>
    <div>
        <Title title="修改个人资料"></Title>
        <div class="information">
            <el-form ref="form"  label-width="80px">
                <el-form-item label="昵称">
                    <el-input v-model="nickName" placeholder="请输入昵称"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                    <el-input v-model="phone" placeholder="请输入手机号"></el-input>
                </el-form-item>
                <el-form-item label="邮箱">
                    <el-input v-model="email" placeholder="请输入邮箱"></el-input>
                </el-form-item>
                 <el-form-item>
                    <el-button type="primary" @click="onSubmit" class="ok">确认</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
<script>
import Title from '../components/Title.vue'
import {changeMsg} from '../api/luntan-getmy.js'
import {getMe} from '../api/luntan-getmy.js'
export default {
     data() {
      return {
        form: {
          nickName: '',
          phone:"",
          email:""
        },
        nickName:"",
        phone:"",
        email:""
      }
    },
    created() {
        getMe().then(res=>{
            console.log(res.data.userName);
            this.nickName = res.data.userName;
            this.phone = res.data.phonenumber;
            this.email = res.data.email
        })
    },
    methods: {
      onSubmit() {
        changeMsg(this.nickName,this.email,this.phone).then(()=>{
            this.open();
            this.$router.back(-1)
        })
        // fffff
      },
      open() {
        this.$notify({
          title: '修改成功',
          type: 'success',
          duration:1500,
          showClose:false,
          position:'top-left'
        });
      },
    },
    components:{
        Title
    }
}
</script>
<style lang="less" scoped>
    .information {
        width: 80%;
        margin: 40px 20px;
        .ok {
            position: relative;
            right: 20px;
        }
    }
</style>